package vfs.server.rmi;

import vfs.common.rmi.AbstractRmiManager;
import vfs.common.rmi.RmiDispatcher;

import java.rmi.AlreadyBoundException;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;

/**
 * Singleton holding server-side RMI operations
 * <p/>
 * User: serge
 * Date: 21.11.13
 * Time: 22:02
 */
public class ServerRmiManager extends AbstractRmiManager
{
    private static final ServerRmiManager ourInstance = new ServerRmiManager();

    private ServerRmiManager()
    {
    }

    public static ServerRmiManager getInstance()
    {
        return ourInstance;
    }

    public void bind(int port, RmiDispatcher dispatcher) throws RemoteException, AlreadyBoundException
    {
        registry = LocateRegistry.createRegistry(port);
        registry.bind(bindName, dispatcher);
    }
}
